var lom = document.querySelector("#lom");
var lon = document.querySelector("#lon");
var out = document.querySelector("#out");


lom.addEventListener('click',function(){

    lon.style.display = 'block';
    darg(lon);
    function darg(obj){
        //鼠标按下
        obj.onmousedown = function(ev){

            //IE直接用event或者window.event得到事件本身,而在其他浏览器函数要获取到事件本身需要从函数中传入
            var oevent = ev || event;

            var distanceX = oevent.clientX - this.offsetLeft;
            var distanceY = oevent.clientY - this.offsetTop;

            //鼠标移动
            document.onmousemove = function(ev){
                var oevent = ev || event;
                obj.style.left = oevent.clientX - distanceX + 'px';
                obj.style.top = oevent.clientY - distanceY + 'px';
            };
            //鼠标放开
            document.onmouseup = function(){
                document.onmousemove = null;
            };
        };
    }
});
out.addEventListener('click',function(){
    lon.style.display = 'none';
    lon.style.right = 0;
    lon.style.bottom = 0;
    lon.style.left = 'auto';
    lon.style.top = 'auto';
});

/*轮播*/
var mySwiper = new Swiper ('.swiper-container', {

    loop: true, // 循环模式选项
    autoplay:true,

    // 如果需要分页器
    pagination: {
        el: '.swiper-pagination'
    },

    // 如果需要前进后退按钮
    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev'
    }
});


var ha = document.querySelector("#ha");
var ls = document.querySelector(".ls");
b = true;
    ha.addEventListener("click",function(){
        if (b){
                ls.style.display = "block";
        }else {
            ls.style.display = "none";
        }
        b =! b;
    });

var top1 = document.querySelector("#top");

 window.onscroll = function() {

 if (document.body.scrollTop > 1000 || document.documentElement.scrollTop > 1000){
 top1.style.display = 'block';
 } else{
 top1.style.display = 'none';
 }

 top1.addEventListener('click',function(){
 window.scrollTo(0,0);
 });
 };


